<!-- 个人中心 -->
<template>
  <div class="context_box_f tabbarBottom">
    <div class="self_top sbFlex" @click="$router.push('/personal-center-info')">
      <div class="self_top_l cenFlex">
        <div class="self_top_l_img img cenFlex">
          <img :src="userInfo.avatarUrl" alt="头像" v-if="userInfo.avatarUrl" />
        </div>
        <div class="self_top_l_name">{{ userInfo.username || "--" }}</div>
      </div>
      <div class="self_top_r">
        <van-icon name="arrow" color="#828482" size="18px" />
      </div>
    </div>
    <div class="self_middle sbFlex" @click="$router.push('/credit-details')">
      <div class="self_middle_l cenFlex">
        <div class="self_middle_l_img img cenFlex">
          <img src="@/assets/img/index_icon3.png" alt="" />
        </div>
        <div class="self_middle_l_name">我的积分</div>
      </div>
      <div class="self_middle_r cenFlex">
        <div style="margin-right: 5px">{{ userInfo.sumScore || "0" }}分</div>
        <div class="self_middle_r_icon cenFlex">
          <van-icon name="arrow" color="#828482" size="18px" />
        </div>
      </div>
    </div>
    <div class="self_middle sbFlex" @click="$router.push('/gift-list')">
      <div class="self_middle_l cenFlex">
        <div class="self_middle_l_img img cenFlex">
          <img src="@/assets/img/index_icon4.png" alt="" />
        </div>
        <div class="self_middle_l_name">积分规则及礼物兑换</div>
      </div>
      <div class="self_middle_r">
        <van-icon name="arrow" color="#828482" size="18px" />
      </div>
    </div>
    <a href="tel:15306814518" style="color: #333">
      <div class="self_middle sbFlex">
        <div class="self_middle_l cenFlex">
          <div class="self_middle_l_img img cenFlex">
            <img src="@/assets/img/index_icon31.png" alt="" />
          </div>
          <div class="self_middle_l_name">联系小纳老师</div>
        </div>
        <div class="self_middle_r">
          <van-icon name="arrow" color="#828482" size="18px" />
        </div>
      </div>
    </a>
  </div>
</template>

<script>
import api from "@/api/user";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      userInfo: {},
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    //   初始获取个人的基本信息
    getuserInfoFn() {
      api.indexUser().then((res) => {
        if (res.code == 0) {
          this.userInfo = res.data || {};
          localStorage.setItem("nice-user", JSON.stringify(res.data));
        }
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.getuserInfoFn();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scoped>
.self_top {
  background: #fff;
  width: 100%;
  height: 75px;
  padding: 0px 20px;
  margin-top: 1px;
  margin-bottom: 15px;
  .self_top_l {
    .self_top_l_img {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      overflow: hidden;
      margin-right: 18px;
    }
  }
}
.self_middle {
  background: #fff;
  width: 100%;
  height: 75px;
  padding: 0px 20px;
  margin-bottom: 5px;
  .self_middle_l {
    .self_middle_l_img {
      width: 30px;
      height: 30px;
      margin-right: 18px;
    }
  }
  .self_middle_r {
    color: $niceblue;
  }
}
</style>